﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Diagnostics;

namespace net.veekee.common.data
{
    public class XMLItem
    {
        public String Name
        {
            get;
            set;
        }

        public String Value
        {
            get;
            set;
        }

        public bool Completed
        {
            get;
            set;
        }

        private Dictionary<String, String> properties = null;
        private Dictionary<String, XMLItem> children = null;

        public XMLItem()
        {
            this.properties = new Dictionary<String, String>();
            this.children = new Dictionary<String, XMLItem>();
        }

        public void AddProperty(String elt, String value)
        {
            try
            {
                if (!this.properties.ContainsKey(elt))
                    this.properties.Add(elt, value);
            }
            catch
            {
            }
        }

        public void AddChild(XMLItem child)
        {
            try
            {
                if (!this.children.ContainsKey(child.Name))
                    this.children.Add(child.Name, child);
            }
            catch
            {
            }
        }

        public String GetProperty(String elt)
        {
            if (this.properties.ContainsKey(elt))
                return this.properties[elt];
            return null;
        }

        public XMLItem GetChild(String name)
        {
            if(this.children.ContainsKey(name))
                return this.children[name];
            return null;
        }
    }
}
